package main;

import java.io.UnsupportedEncodingException;
import java.security.Key;
import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

import security.CASSecurityImpl;
import security.LoginInfo;
import util.RSAUtil;

public class TestRSA {
	public static void main(String[] args) throws Exception {
		CASSecurityImpl cas = new CASSecurityImpl();
		KeyPair userPair = RSAUtil.generateKeyPair();
		KeyPair ssbPair = RSAUtil.generateKeyPair();
		KeyPair serPair = RSAUtil.generateKeyPair();
		
		RSAPublicKey usrPub = (RSAPublicKey) userPair.getPublic();
		RSAPrivateKey usrPri = (RSAPrivateKey) userPair.getPrivate();
		RSAPublicKey ssbPub = (RSAPublicKey) ssbPair.getPublic();
		RSAPrivateKey ssbPri = (RSAPrivateKey) ssbPair.getPrivate();
		RSAPublicKey serPub = (RSAPublicKey) serPair.getPublic();
		RSAPrivateKey serPri = (RSAPrivateKey) serPair.getPrivate();
		
//		LoginInfo li = new LoginInfo();
//		li.setUsername("CAS");
//		li.setRAname("name");
//		li.setPassword("CAS");
//		cas.login(li, RSAUtil.generateKeyHolder(usrPub));
		generateCASLicenceNo(cas);
		
		
	}

	private static void generateCASLicenceNo(CASSecurityImpl cas)
			throws UnsupportedEncodingException, Exception {
		/*String passportid = "e5a519a6-f95e-41df-bd88-8250863335b2";
		String casPub_pwd = RSAUtil.sEncrypt((Key) RSAUtil.retriveKey("CAS-PUB"), passportid);
		String sig = RSAUtil.doSSign((RSAPrivateKey) RSAUtil.retriveKey("CAS-PRI"), casPub_pwd);
		cas.getNew(RSAUtil.generateSignedData(casPub_pwd, sig), RSAUtil.generateKeyHolder((RSAPublicKey) RSAUtil.retriveKey("CAS-PUB")));
	*/}
}
